package com.itheima.test;

import java.util.ArrayList;

public class StudentOperatorImpl2 implements StudentOperator {
    @Override
    public void printAll(ArrayList<Student> stus) {
        int count1 = 0;
        int count2 = 0;
        System.out.println("----------学生全部信息-----------");
        for (Student student : stus) {
            if (student.getSex() == '男') {
                count1++;
            } else {
                count2++;
            }
            System.out.println(student);
        }
        System.out.println("男生人数：" + count1);
        System.out.println("女生人数：" + count2);
    }

    @Override
    public void printAvgScore(ArrayList<Student> stus) {
        System.out.println("----------学生全部信息-----------");
        Double allScore = 0.0;
        Double maxScore = 0.0;
        Double minScore = 0.0;
        for (Student student : stus) {
            allScore += student.getScore();
            if (student.getScore() > maxScore) {
                maxScore = student.getScore();
            }
            if (student.getScore() < minScore) {
                minScore = student.getScore();
            }
        }
        System.out.println("最高成绩：" + maxScore);
        System.out.println("最低成绩：" + minScore);
        System.out.println(String.format("%.2f",allScore - maxScore - minScore / stus.size() - 2));
    }
}
